<?php
// Wrapper for tweeting through GET
session_start();
require_once('../twitterlib/twitteroauth/twitteroauth.php');
require_once('../config.php');
require_once('../SQLfunc.php');
require_once('../func.php');

$auth=array();
$gotcha = getAuth($auth);
if(!$gotcha)
{
	die("No token/token secret");
}

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $auth['token'], $auth['token_secret']);

switch ($_GET['action']) {
	case 'tweet':
		// It's a reply
		if ($reply!=0)
		{
			$connection->post('statuses/update', array('status' => $_GET['twText'], 'in_reply_to_status_id' => $_GET['tid']));
		}
		else // It's a normal tweet.
		{
			$connection->post('statuses/update', array('status' => $_GET['twText']));
		}
		break;
	case 'unfav':
		// Unfavorite the tweet.
		$connection->post('favorites/destroy', array('id' => $_GET['tid']));
		break;
	case 'retweet':
		// Create a retweet.
		$connection->post('statuses/retweet', array('id' => $_GET['tid']));
		break;
	default:
		echo "No action requested";
}

		
print($connection->http_info['http_code']);
?>